<link type="text/css" href="/admins/js/jquery/css/ui-lightness/jquery-ui-1.8.20.custom.css" rel="stylesheet" />
<script type="text/javascript" src="/admins/js/My97DatePicker/WdatePicker.js"></script>
<script>
    
</script>
<div class="admin_nrtop">
    <div class="ad_search">
        <form action="/admini/visiting/index/"  method="post" style="margin:0px" id="form1">
        <div class="search">
            <div class="soubox">
                <input type="text" id="quick" name="quick" value="<?php echo $this->quick?$this->quick:"";?>" placeholder="输入仓库号/物流单号/取件单号等"/>
                <input type="hidden" id="timescope" name="timescope" value="<?php echo $this->timescope?$this->timescope:"";?>" />
                <input type="hidden" id="starttime" name="starttime" value="<?php echo $this->starttime?$this->starttime:"";?>"/>
                <input type="hidden" id="endtime" name="endtime" value="<?php echo $this->endtime?$this->endtime:"";?>" />
                <input type="hidden" id="pagesize" name="pagesize" value="<?php echo $this->pagesize?$this->pagesize:10;?>" />
                <input type="hidden" id="cityId" name="cityId" value="<?php echo $this->cityId?$this->cityId:"";?>" />
                <input type="hidden" id="townId" name="townId" value="<?php echo $this->townId?$this->townId:"";?>" />
                <input type="hidden" id="startweight" name="startweight" value="<?php echo $this->startweight?$this->startweight:"";?>"/>
                <input type="hidden" id="endweight" name="endweight" value="<?php echo $this->endweight?$this->endweight:"";?>" />
                <input type="hidden" id="startvolume" name="startvolume" value="<?php echo $this->startvolume?$this->startvolume:"";?>"/>
                <input type="hidden" id="endvolume" name="endvolume" value="<?php echo $this->endvolume?$this->endvolume:"";?>" />
                <input type="hidden" id="startmoney" name="startmoney" value="<?php echo $this->startmoney?$this->startmoney:"";?>"/>
                <input type="hidden" id="endmoney" name="endmoney" value="<?php echo $this->endmoney?$this->endmoney:"";?>" />
                <input type="hidden" id="isWay" name="isWay" value="<?php echo ($this->isWay !== "" && $this->isWay !== null)?$this->isWay:"";?>" />
                <input type="hidden" id="interiorId" name="interiorId" value="<?php echo ($this->interiorId !== "" && $this->interiorId !== null)?$this->interiorId:"";?>" />
                
            </div>
            <a href="javascript:$('#form1').submit();"><span>搜索</span></a>
        </div>

        <div class="timebox">
            <div class="ad_time">
                <div class="timezdy">
                    <div class="timeselect2">
                        <span><?php if($this->timescope){
                                switch ($this->timescope) {
                                    case "week":
                                        echo "本周";
                                        break;
                                    case "lastweek":
                                        echo "上周";
                                        break;
                                    case "month":
                                        echo "本月";
                                        break;
                                    case "lastmonth":
                                        echo "上月";
                                        break;
                                    case "quarter":
                                        echo "本季";
                                        break;
                                    case "lastquarter":
                                        echo "上季";
                                        break;
                                    case "year":
                                        echo "今年";
                                        break;
                                    case "lastyear":
                                        echo "去年";
                                        break;
                                    case "day7":
                                        echo "近7天";
                                        break;
                                    case "day30":
                                        echo "近30天";
                                        break;
                                    default:
                                        echo "范围选择";
                                        break;
                                }
                            }else{echo "范围选择";}?>
                        </span><i></i>
                    </div>
                    <div class="timeslelct_xl" style="display:none;">
                        <ul>
                            <li><a href="javascript:setstart('week')">本周</a></li>
                            <li><a href="javascript:setstart('lastweek')">上周</a></li>
                            <li><a href="javascript:setstart('month')">本月</a></li>
                            <li><a href="javascript:setstart('lastmonth')">上月</a></li>
                            <li><a href="javascript:setstart('quarter')">本季</a></li>
                            <li><a href="javascript:setstart('lastquarter')">上季</a></li>
                            <li><a href="javascript:setstart('year')">今年</a></li>
                            <li><a href="javascript:setstart('lastyear')">去年</a></li>
                            <li><a href="javascript:setstart('day7')">近7天</a></li>
                            <li><a href="javascript:setstart('day30')">近30天</a></li>
                        </ul>
                    </div>
                </div>
                <div class="timefw">
                    <div class="time">
                        <!--点击后悬停样式为：<div class="timeselect t_on">-->
                        <div class="timeselect"  id="stime">
                            <span id="stimeval"><?php echo $this->starttime?$this->starttime:date("Y-m-d",mktime(0,0,0,date("m"),date("d")-90,date("Y")));?></span><i></i>
                        </div>
                        <div class="timeslelctbox">
                            <!---时间插件放此DIV-->
                        </div>
                    </div>
                    <div class="timezhi">
                        <span>至</span>
                    </div>
                    <div class="time" >
                        <div class="timeselect" id="etime">
                            <span id="etimeval"><?php echo $this->endtime?$this->endtime:date("Y-m-d");?></span><i></i>
                        </div>
                        <div class="timeslelctbox">
                            <!---时间插件放此DIV-->
                        </div>
                    </div>
                </div>
            </div>
            <div class="timeok">
                <a href="javascript:$('#form1').submit();">确定</a>
            </div>
        </div>
        <div class="xianshi">
            <label>显示：</label>
            <ul>
                <li <?php echo $this->pagesize?($this->pagesize==10?'class="xson"':""):'class="xson"'; ?>><a href="javascript:setpagesize(10)">10</a></li>
                <li <?php echo $this->pagesize?($this->pagesize==20?'class="xson"':""):""; ?>><a href="javascript:setpagesize(20)">20</a></li>
                <li <?php echo $this->pagesize?($this->pagesize==30?'class="xson"':""):""; ?>><a href="javascript:setpagesize(30)">30</a></li>
            </ul>
        </div>
        </form>
    </div>
</div>
<div  class="biaoge">
    <div class="biaotbody">
        <table>
            <tr>
                <th class="li205">
                    <div class="lijz"><input name="" type="checkbox" value=""></div>
                </th>
                <th class="li9">
                    <div class="lileft">取件编号</div>
                </th>
                <th class="li8">
                    <div class="lileft">
                        <span>顺丰订单号</span>
                    </div>
                </th>
                <th class="li8">
                    <div class="lileft">
                        <span>顺丰快递号</span>
                    </div>
                </th>
                <th class="li10">
                        <div class="lileft">物品信息</div>
                </th>
                <th class="li17">
                    <div class="biaoxiala">
                        <div class="lixiala">
                            <span>取件地址</span>
                            <i></i>
                        </div>
                        <div class="biaofw" style="display:none;width: 400px;">
                            <select id="affirmCityId" name="affirmCityId" style="float:left;padding: 5px;">
                                <?php foreach ($this->cityAll as $cityVal) {
                                    echo "<option value='".$cityVal["id"]."' ".($cityVal["id"] == $this->cityId?"selected":"")." >".$cityVal["name"]."</option>";
                                }?>
                            </select>
                            <select id="affirmTownId" name="affirmTownId" style="float:left;padding: 5px;">
                                <?php foreach ($this->townAll as $townVal) {
                                    echo "<option value='".$townVal["id"]."' ".($townVal["id"] == $this->townId?"selected":"")." >".$townVal["name"]."</option>";
                                }?>
                            </select>
                            <a href="javascript:void()" id='CityTownConfirm'>确定</a>
                        </div>
                    </div>
                </th>
                <th class="li7">
                    <div class="lileft">仓库号/用户名</div>
                </th>
                <th class="li7">
                    <div class="biaoxiala">
                        <div class="lixiala">
                            <span>物品重量(kg)</span>
                            <i></i>
                        </div>
                        <div class="biaofw" style="display:none;">
                            <input type="text" name='weightstart' id='weightstart' onkeyup="value=value.replace(/[^\d]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"/>
                            <span>至</span>
                            <input type="text" name='weightend' id='weightend' onkeyup="value=value.replace(/[^\d]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"/>
                            <a href="javascript:void()" id='weightConfirm'>确定</a>
                        </div>
                    </div>
                </th>
                <th class="li7">
                    <div class="biaoxiala">
                        <div class="lixiala">
                            <span>体积重量(kg)</span>
                            <i></i>
                        </div>
                        <div class="biaofw" style="display:none;">
                            <input type="text" name="volumestart" id="volumestart" onkeyup="value=value.replace(/[^\d]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"/>
                            <span>至</span>
                            <input type="text" name="volumeend" id="volumeend" onkeyup="value=value.replace(/[^\d]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"/>
                            <a href="javascript:void()" id="volumeConfirm">确定</a>
                        </div>
                    </div>
                </th>
                <th class="li6">
                    <div class="biaoxiala">
                        <div class="lixiala">
                            <span>运费(￥)</span>
                            <i></i>
                        </div>
                        <div class="biaofw" style="display:none;">
                            <input type="text" name="moneystart" id="moneystart" onkeyup="value=value.replace(/[^\d]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"/>
                            <span>至</span>
                            <input type="text" name="moneyend" id="moneyend" onkeyup="value=value.replace(/[^\d]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"/>
                            <a href="javascript:void()" id="moneyConfirm">确定</a>
                        </div>
                    </div>
                </th>
                <th class="li7">
                    <div class="biaoxiala">
                        <div class="lixiala">
                            <span>类型</span>
                            <i></i>
                        </div>
                        <div class="biaoxllb" style="display:none;">
                            <ul>
                                <li><a href="javascript:visitingType(0)">存入仓库</a></li>
                                <li><a href="javascript:visitingType(1)">发往海外</a></li>
                            </ul>
                        </div>
                    </div>
                </th>
                <th class="li5">
                    <div class="biaoxiala">
                        <div class="lixiala">
                            <span>状态</span>
                            <i></i>
                        </div>
                        <div class="biaoxllb" style="display:none;">
                            <ul>
                                <?php foreach ($this->interiorAll as $key => $interiorVal) { ?>
                                    <li><a href="javascript:condition(<?php echo $key;?>)"><?php echo $interiorVal;?></a></li>
                                <?php }?>
                            </ul>
                        </div>
                    </div>
                </th>
                <th class="li6"><div class="liright">操作</div></th>
            </tr>
        </table>
    </div>
    <?php if($this->cityId  || $this->startweight || $this->startvolume || $this->startmoney || ($this->isWay !== "" && $this->isWay !== null) || ($this->interiorId !== "" && $this->interiorId !== null)){?>
       <div class="xzinfo xz48">
         <ul>
            <?php if($this->cityId){ ?>
                <li>
                    <div class="xzinfobox">
                        <span><?php $cityItem = Application_Model_city::load($this->cityId);$townItem = Application_Model_city::load($this->townId);echo $cityItem->name.$townItem->name;?></span>
                        <a href="javascript:removeset('city')" title="撤销"><i>撤销</i></a>
                    </div>
                </li>
            <?php }?>
             <?php if($this->startweight){ ?><li><div class="xzinfobox"><span>物品重亮：<?php echo $this->startweight."kg 至 ".$this->endweight."kg";?></span><a href="javascript:removeset('weight')" title="撤销"><i>撤销</i></a></div></li><?php }?>
             <?php if($this->startvolume){ ?><li><div class="xzinfobox"><span>物品体积：<?php echo $this->startvolume."kg 至 ".$this->endvolume."kg";?></span><a href="javascript:removeset('volume')" title="撤销"><i>撤销</i></a></div></li><?php }?>
             <?php if($this->startmoney){ ?><li><div class="xzinfobox"><span>国内运费：<?php echo "￥".$this->startmoney." 至 ".$this->endmoney;?></span><a href="javascript:removeset('money')" title="撤销"><i>撤销</i></a></div></li><?php }?>
             <?php if($this->isWay === "" || $this->isWay === null){}else{ ?><li><div class="xzinfobox"><span><?php echo $this->isWay==1?"发往国外":"存入仓库";?></span><a href="javascript:removeset('isWay')" title="撤销"><i>撤销</i></a></div></li><?php }?>
             <?php if($this->interiorId === "" || $this->interiorId === null){}else{ ?><li><div class="xzinfobox"><span><?php echo $this->interiorAll[$this->interiorId];?></span><a href="javascript:removeset('interior')" title="撤销"><i>撤销</i></a></div></li><?php }?>
         </ul>
     </div>
    <?php }?>
     <div class="table">
         <table>
             <?php foreach ($this->visitingList as $Item) { ?> 
                <tr <?php echo in_array($Item->userId,$this->paypalBill) ? "" : "style='display:none;'" ?>>
                            <td colspan="6" style="padding-left: 20px;color: #c00;">
                               客户第一次国际信用卡支付，24小时风险审核后自动解除服务限制！
                            </td>
                        </tr>

                 <tr>
                     <td class="li205"><div class="lijz"><input type="checkbox" id="chk<?php echo $Item->id; ?>" name="ID" /></div></td>
                     <td class="li9">
                         <div class="lileft yubm">
                             <p><a href="/admini/visiting/vsdetail/id/<?php echo $Item->id; ?>"><?php echo $Item->visitingNo; ?></a></p>
                             <span><?php echo $Item->dateCreated;?></span>
                         </div>
                     </td>
                     <td class="li8">
                         <div class="lileft">
                             <?php echo $Item->sfNo?$Item->sfNo:"暂无";?>
                        </div>
                     </td>
                     <td class="li8">
                         <div class="lileft">
                             <?php echo $Item->inlandLogistics?$Item->inlandLogistics:"暂无";?>
                        </div>
                     </td>
                     <td class="li10">
                         <div class="lileft">
                             <?php echo $Item->waresName;?>
                        </div>
                     </td>
                     <td class="li17">
                         <div class="lileft">
                             <?php echo "中国".$Item->CityByCityId->name.$Item->TownBy->name.$Item->inlandAddress;?>
                        </div>
                     </td>
                     <td class="li7">
                         <div class="lileft yonghu">
                             <p><a href="/admini/visiting/index/quick/<?php echo $Item->UserInfo->storeno;?>"><?php echo $Item->UserInfo!=null?$Item->UserInfo->storeno:"用户出错"; ?></a></p>
                             <h3><a href="/admini/manageuser/userdetail/id/<?php echo $Item->UserInfo?$Item->userinfo->id:""; ?>"><?php echo $Item->UserInfo!=null?$Item->UserInfo->nikename:"用户出错"; ?></a></h3>
                         </div>
                     </td>
                     <td class="li7">
                         <div class="lileft"> 
                             <?php echo $Item->estimateWeight/1000;?>
                         </div>
                     </td>
                     <td class="li7">
                         <div class="lileft">
                             <?php echo $Item->estimateVolume/1000;?>
                         </div>
                     </td>
                     <td class="li6">
                         <div class="lileft">
                             <?php echo $Item->inlandMoney;?>
                         </div>
                     </td>
                     <td class="li7">
                         <div class="lileft">
                             <?php echo $Item->isWay == 1?"发往海外<br>".$Item->WayBill->UserCity->name:"存入仓库"; ?>
                         </div>
                     </td>
                     <td class="li5">
                        <div class="lileft">
                            <?php echo $Item->InteriorName;?>
                        </div>
                     </td>
                     <td class="li6">
                         <div class="lixlnav">
                             <a class="xlnavxq" href="/admini/visiting/vsdetail/id/<?php echo $Item->id; ?>">详情</a>
                             <div class="xlnavlistbox">
                                 <a class="xlnavsj" href="javascript:void();"><i></i></a>
                                 <div class="xlnavlist" style="display:none;">
                                     <ul>
                                             <li><a href="/admini/managestore/storedetail/id/<?php echo $Item->id;?>/quickedit/edit">编辑</a></li>
                                             <li><a href="javascript:deleteById(<?php echo $Item->id; ?>)" name="<?php echo $Item->visitingNo; ?>">回收站</a></li>
                                     </ul>
                                 </div>
                             </div>
                         </div>
                     </td>
                 </tr>
             <?php }  if(!$this->visitingList){
                echo "<font size='4' color='red'>暂无数据</font>";
                }?>   
         </table>
     </div>
 </div>
<div class="toolbar">
    <?php if($this->stype == Application_Model_wayBillItem::Interior_AffirmChannel && $this->billlist){ ?>
    <div class="qunx">
        <ul>
            <li><a class="anvbotton" href="/admini/managewaybill/outstorage" id="printOut" name="printOut"><span>打印交接单</span></a></li>
            <li><a class="anvbotton" href="javascript:void(0)" id="AffirmChannel" name="AffirmChannel"><span>交运</span></a></li>
            <li><a class="anvbotton4" href="javascript:void(0)" id="ckall" name="ckall"><span>全选</span></a></li>
        </ul>
    </div>
    <?php } ?>
<?php
echo $this->partial('paging.phtml', array("pages" => $this->visitingAll,"pamas"=>"balusc=$this->balusc&timescope=$this->timescope&starttime=$this->starttime&endtime=$this->endtime&pagesize=$this->pagesize&cityId=$this->cityId&townId=$this->townId&startweight=$this->startweight&endweight=$this->endweight&startvolume=$this->startvolume&endvolume=$this->endvolume&startmoney=$this->startmoney&endmoney=$this->endmoney&isWay=$this->isWay&interiorId=$this->interiorId"));        
?>
</div>
<script>
    $(".timezdy").click(function(){
        $(".timezdy .timeselect2").attr("class","timeselect2 timeon");
        $(".timeslelct_xl").show();
    });
    $(".timezdy").mouseleave(function(){
       $(".timeselect2").attr("class","timeselect2");
       $(".timeslelct_xl").hide();
    });
    function setpagesize(size)
    {
        $(".xianshi ul li").attr("class","");
        $(".soubox #pagesize").val(size);
        $('#form1').submit();
    }
    $("#stime").click(function(){
        $(this).attr("class","timeselect t_on");
        WdatePicker({el:'stimeval',vel:'starttime',onpicked:function(){
                $("#stime,#etime").attr("class","timeselect");
                $(".soubox #timescope").val("");
        }});
    });
    $("#etime").click(function(){
        $(this).attr("class","timeselect t_on");
        WdatePicker({el:'etimeval',vel:'endtime',onpicked:function(){
                $("#stime,#etime").attr("class","timeselect");
                $(".soubox #timescope").val("");
        }});
    });
    function setstart(start)
    {
        $(".soubox #timescope").val(start);
        $(".timeselect2").attr("class","timeselect2");
        $(".timeslelct_xl").attr("style","display:none;");
        $('#form1').submit();
    }
    $(".lixiala").click(function(){
        $(".lixiala").attr("class","lixiala");
        $(".lixiala").next("div").hide();
    
        $(this).attr("class","lixiala bton");
        $(this).next("div").show();
    });
    $(".xlnavsj").live("mousemove",function(){
        $(this).next("div").show();
    });
    $(".lixlnav").mouseleave(function(){
        $(".xlnavsj").next("div").hide();
    });
    $("#affirmCityId").bind("change",function(){
        var cityid = $(this).val();
        $.ajax({    
            type: 'POST',
            url: '/admini/visiting/citysubtown/cityid/'+cityid,
            success: function(data) {
                if(data){
                    var html = "";
                    $.each(data, function(key, val) {
                        html+= '<option value="'+val.id+'">'+val.name+'</option>';
                    });
                    $("#affirmTownId").html(html);
                 }
            }
        });
    });
    $(document).bind("click",function(e){
        var target  = $(e.target);
        if(target.closest(".biaoxiala").length == 0){
            $(".lixiala").attr("class","lixiala");
            $(".lixiala").next("div").hide();
        }
        if(target.closest("#stime").length == 0){
            $("#stime").attr("class","timeselect");
        }
        if(target.closest("#etime").length == 0){
            $("#etime").attr("class","timeselect");
        }
   });
    $('.countryzm a').each(function(index,item){
        $(item).click(function(){
            $('.countryzm li.zmon').removeClass('zmon');
            $(this).parent().addClass('zmon');
            $('#countryTab ul').hide();
            $('#countryTab ul').eq(index).show();
            return false;
        });
    });
     $('.countrylist a').bind('click',function(){
         $(".soubox #cityid").val($(this).attr('cid'));
         $('#form1').submit();
     });
     $("#CityTownConfirm").click(function(){
         var cityId = $("#affirmCityId").val();
         var townId = $("#affirmTownId").val();
         $(".soubox #cityId").val(cityId);
         $(".soubox #townId").val(townId);
         $('#form1').submit();
     });
    $("#weightConfirm").click(function(){
        var weightstart = $("#weightstart").val();
        var weightend = $("#weightend").val();
        if($.trim(weightstart) == ""){
            alert("开始物品净重不能为空");
            return false;
        }else{
            $(".soubox #startweight").val(weightstart);
        }
        if($.trim(weightend) == ""){
            alert("结束物品净重不能为空");
            return false;
        }else{
            $(".soubox #endweight").val(weightend);
        }
        $('#form1').submit();
    });
    $("#volumeConfirm").click(function(){
        var volumestart = $("#volumestart").val();
        var volumeend = $("#volumeend").val();
        if($.trim(volumestart) == ""){
            alert("开始体积不能为空");
            return false;
        }else{
            $(".soubox #startvolume").val(volumestart);
        }
        if($.trim(volumeend) == ""){
            alert("结束体积不能为空");
            return false;
        }else{
            $(".soubox #endvolume").val(volumeend);
        }
        $('#form1').submit();
    });
    $("#moneyConfirm").click(function(){
        var moneystart = $("#moneystart").val();
        var moneyend = $("#moneyend").val();
        if($.trim(moneystart) == ""){
            alert("开始国内运费不能为空");
            return false;
        }else{
            $(".soubox #startmoney").val(moneystart);
        }
        if($.trim(moneyend) == ""){
            alert("结束国内运费不能为空");
            return false;
        }else{
            $(".soubox #endmoney").val(moneyend);
        }
        $('#form1').submit();
    });
    function visitingType(id)
    {
        $(".soubox #isWay").val(id);
        $('#form1').submit();
    }
    function condition(id)
    {
        $(".soubox #interiorId").val(id);
        $('#form1').submit();
    }
    function removeset(type)
    {
        if(type == "city"){
            $(".soubox #cityId").val("");
            $(".soubox #townId").val("");
        }else if(type == "weight"){
            $(".soubox #startweight").val("");
            $(".soubox #endweight").val("");
        }else if(type == "volume"){
            $(".soubox #startvolume").val("");
            $(".soubox #endvolume").val("");
        }else if(type == "money"){
            $(".soubox #startmoney").val("");
            $(".soubox #endmoney").val("");
        }else if(type == "isWay"){
            $(".soubox #isWay").val("");
        }else if(type == "interior"){
            $(".soubox #interiorId").val("");
        }
        $('#form1').submit();
    }
    
    function deleteById(id){
        if(confirm("确认要删除！")){
            $.post(
                '/admini/visiting/deletebyid',
                {'id':id},
                function (data){
                    if(data === 1){
                        alert("删除成功！");
                        location.reload();
                    }else{
                        alert("删除失败！");
                    }
                }
            ,'json');
        }
    }
</script>
